package com.gws.juc;

import java.util.concurrent.CountDownLatch;

/**
 * 计数器
 * 执行完其他线程后，在执行main线程
 * @author gws
 * 减
 *
 */
public class CountDownLatchDemo {
	
	public static void main(String[] args) throws Exception {
		
		CountDownLatch countDownLatch = new CountDownLatch(6);
		
		for (int i = 0; i < 6; i++) {
			new Thread(() -> {
				System.out.println(Thread.currentThread().getName()+": 离开教室");
				countDownLatch.countDown();
			},String.valueOf(i)).start();
		}
		countDownLatch.await();
		System.out.println("main关闭教室门");
		
		
	}

}
